/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AboutPanel.java
 *
 * Created on 26.09.2010, 19:15:38
 */

package rosedb.gui;

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
import riulib.helpers.ScaleImage;
import rosedb.control.Controller;
import rosedb.model.Logger;

/**
 *
 * @author riu
 */
public class AboutPanel extends javax.swing.JPanel {

    /** Creates new form AboutPanel */
    public AboutPanel() {
        initComponents();

        setOpaque(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        lb_version = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jPanel1 = this.new Pic();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();

        setMaximumSize(null);
        setPreferredSize(new java.awt.Dimension(477, 160));

        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Erstellt von:");

        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Michael Scherbakow");

        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Version: ");

        lb_version.setForeground(new java.awt.Color(255, 255, 255));
        lb_version.setText(Controller.VERSION);

        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Kontakt:");

        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("michael.scherbakow@googlemail.com");

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 100, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 100, Short.MAX_VALUE)
        );

        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("Daten:");

        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText(System.getProperty("user.home")+System.getProperty("file.separator")+"Library"+System.getProperty("file.separator")+"rose_db");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel6)
                    .add(jLabel1)
                    .add(jLabel3)
                    .add(jLabel4))
                .add(12, 12, 12)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel5)
                    .add(lb_version)
                    .add(jLabel2)
                    .add(jLabel7))
                .add(268, 268, 268))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel1)
                            .add(jLabel2))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lb_version))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel4)
                            .add(jLabel5)))
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel7)
                    .add(jLabel6))
                .addContainerGap(34, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lb_version;
    // End of variables declaration//GEN-END:variables


    private class Pic extends JPanel{
        BufferedImage img;
        ScaleImage.Rectangle p;

        public Pic() {
            setOpaque(false);
            try {
                img = ImageIO.read(this.getClass().getResourceAsStream("/rosedb/resources/me.jpg"));
            } catch (IOException ex) {
                Logger.log(ex);
            }
        }

        public void load(){
            if(p==null){
                ScaleImage.Rectangle o = new ScaleImage.Rectangle(0, 0, getWidth(), getHeight());
                p = ScaleImage.fitToRect(o, img);
                img = ScaleImage.scale(img, p.width, p.heigth);
            }
        }

        @Override
        public void paint(Graphics g) {
            super.paint(g);
            load();
            g.drawImage(img, p.x, p.y, p.width, p.heigth, this);
        }


    }
}
